/*
 * Copyright (c) 2020 Carnegie Lee
 * All rights reserved
 */
package com.geektech.mybatis.handler;

import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl;

import java.sql.Types;

/**
 * Mybatis Generator JavaTypeResolver 强化
 * 将Long、Integer、Short、Float、Double、Boolean等类型的JDBC转换
 * 为long、int、short、float、double、boolean类型
 *
 * @author Carnegie Lee
 */
public class JavaTypeResolverPreferImpl extends JavaTypeResolverDefaultImpl {
    public JavaTypeResolverPreferImpl() {
        super();
        super.typeMap.put(Types.BIGINT, new JdbcTypeInformation("BIGINT",
                new FullyQualifiedJavaType(long.class.getName())));
        super.typeMap.put(Types.INTEGER, new JdbcTypeInformation("INTEGER",
                new FullyQualifiedJavaType(int.class.getName())));
        super.typeMap.put(Types.SMALLINT, new JdbcTypeInformation("SMALLINT", //$NON-NLS-1$
                new FullyQualifiedJavaType(short.class.getName())));
        super.typeMap.put(Types.REAL, new JdbcTypeInformation("REAL", //$NON-NLS-1$
                new FullyQualifiedJavaType(float.class.getName())));
        super.typeMap.put(Types.DOUBLE, new JdbcTypeInformation("DOUBLE", //$NON-NLS-1$
                new FullyQualifiedJavaType(double.class.getName())));
        super.typeMap.put(Types.FLOAT, new JdbcTypeInformation("FLOAT", //$NON-NLS-1$
                new FullyQualifiedJavaType(double.class.getName())));
        super.typeMap.put(Types.BIT, new JdbcTypeInformation("BIT", //$NON-NLS-1$
                new FullyQualifiedJavaType(boolean.class.getName())));
        super.typeMap.put(Types.BOOLEAN, new JdbcTypeInformation("BOOLEAN", //$NON-NLS-1$
                new FullyQualifiedJavaType(boolean.class.getName())));
    }
}
